#ifndef DIALOG_ADRESS_MANAGER_H
#define DIALOG_ADRESS_MANAGER_H

#include <QDialog>
#include <QMessageBox>
#include <QTimer>
#include <QListWidgetItem>
#include <QShowEvent>
#include <QKeyEvent>
#include "adress.h"
#include "keyboard.h"
#include "database_manager.h"

enum field
{
    CONTINENT, COUNTRY, TOWN, WAY, NUMERO
};

namespace Ui {
    class Dialog_Adress_Manager;
}

class Dialog_Adress_Manager : public QDialog
{
    Q_OBJECT

protected:
    void showEvent ( QShowEvent * event );

public:
    explicit Dialog_Adress_Manager(Adress * a, QWidget *parent = 0);
    ~Dialog_Adress_Manager();
    void Change_Theme(QString theme_name, QString style);
    void setAdress(Adress * adress, bool replace = false);
    void setKeyboard(Keyboard * kb);
    field current_field;
    //Adress & get_Current_Adress(){ return *Current_Adress; }

private:
    Ui::Dialog_Adress_Manager *ui;
    bool Virtual_Keyboard;
    Adress * Current_Adress;
    Adress * Temp_Adress;
    Keyboard * keyboard;
    Database_manager * db_manager;

public slots:
    void Validate();
    void Init_All();
    void Init_Continent(bool keep);
    void Init_Country(bool keep);
    void Init_Town(bool keep);
    void Init_Way(bool keep);
    void Init_Numero(bool keep);
    void setVirtualKeyboard(bool enable);
    bool Valid_Continent();
    bool Valid_Country();
    bool Valid_Town();
    bool Valid_Way();
    bool Valid_Numero();
    void Modify_Continent();
    void Modify_Country();
    void Modify_Town();
    void Modify_Way();
    void Modify_Numero();
    void Clear_Continent();
    void Clear_Country();
    void Clear_Town();
    void Clear_Way();
    void Clear_Numero();
    void Clear_Suggestions(bool remove = false);
    void Suggestions_Continent(QString text = "");
    void Suggestions_Country(QString text = "");
    void Suggestions_Town(QString text = "");
    void Suggestions_Way(QString text = "");
    void Suggestions_Numero(QString text = "");

    void Favorite_Clicked();
    void List_Suggestion_Clicked(QListWidgetItem* item);
    void Get_List_Favorites();

    void Get_Adress_Info(Adress * a, long id);

    Database_manager * Get_Manager(){ return db_manager; }
};

#endif // DIALOG_ADRESS_MANAGER_H
